using AutoMapper;
using Pay.DTO;
using Pay.Data;
using Pay.IService;
using Pay.Core;

namespace Pay.Service.AutoMapper {
	public class RefundMapper : IStartupDto {
		private IMapperConfigurationExpression _cfg;
		public RefundMapper(IMapperConfigurationExpression cfg) {
			_cfg = cfg;
		}
		public void Execute() {
			Create();
		}
		protected virtual void Create() {
			_cfg.CreateMap<Refund, refund_dto>()
				.ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
				.ForMember(dest => dest.order_no, src => src.MapFrom(c => c.OrderNo))
				.ForMember(dest => dest.charge_id, src => src.MapFrom(c => c.ChargeId))
				.ForMember(dest => dest.amount, src => src.MapFrom(c => c.Amount))
				.ForMember(dest => dest.apply_time, src => src.MapFrom(c => c.ApplyTime.ToDateTime()))
				.ForMember(dest => dest.status, src => src.MapFrom(c => c.Status))
				.ForMember(dest => dest.pay_id, src => src.MapFrom(c => c.PayId))
				.ForMember(dest => dest.refund_time, src => src.MapFrom(c => c.RefundTime.ToDateTime()))
				.ForMember(dest => dest.pay_info, src => src.MapFrom(c => c.PayInfo));
		}
	}
}
